<?php
namespace app\admin\validate;

use think\Validate;

class TemplateValidate extends Validate
{
    protected $rule = [
        'name' => 'require',
        'mark' => 'require',
        "id" => 'require',
        "sort"=>'require|number',
        "status" => 'require|in:1,-1',
        'sms_content' => 'requireWithout:email_content',
        'email_content'  => 'requireWithout:sms_content',
    ];

    protected $message = [
        'name.require' => '模板名称必须填写',
        'name.unique'=>"模板名称已经存在",
        'mark.require' => '模板标识必须填写',
        'mark.unique'=>"模板标识已经存在",
        "id.require" => "缺少id",
        "sort.require"=>"排序必须填写",
        "sort.number"=>"排序必须是数字",
        "status.in" => "状态值错误",
        "status" => "缺少状态值",
        "sms_content.requireWithout" => '短信邮箱内容至少填一个',
        "email_content.requireWithout" => '短信邮箱内容至少填一个',
    ];

    protected $scene = [
        'add' => ['name','sort','mark','email_content','sms_content'],
        'edit' => ['name','id','sort','mark','email_content','sms_content'],
        'status'=>['id','status'],
    ];
}